/** 实现继承
 * @param {function} SubType // 子类构造函数
 * @param {function} SuperType // 父类构造函数
 * @return {undefined}
 */
function inheritPrototype(SubType, SuperType) {
  SubType.prototype = Object.create(SuperType.prototype)
  Object.defineProperty(SubType.prototype, "constructor", {
    enumerable: false,
    configurable: true,
    writable: true,
    value: SubType
  })
}

// 父类
function Person(name, age, friends) {
  this.name = name
  this.age = age
  this.friends = friends
}

Person.prototype.running = function() {
  console.log('running')
}

Person.prototype.eating = function() {
  console.log('eating')
}

// 子类
function Student(name, age, friends, sno, score) {
  Person.call(this, name, age, friends)
  this.sno = sno
  this.score = score
}

inheritPrototype(Student, Person) // 实现继承

Student.prototype.studying = function() {
  console.log('studying')
}

var stu = newStudent('why', 19, ['kobe'], 111, 100)
console.log(stu)
stu.studying()
stu.running()
stu.eating()